<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@ taglib uri="http://paycn.com.cn/pos" prefix="p"%>

<script type="text/javascript"
	src="<c:url value="/static/js/bootstrap-datepicker.js"/>"></script>


<form id="member-form" action="<c:url value="/vacation/save.html"/>"
	method="post" class="form-horizontal">

	<div class="row-fluid">
		<div class="span12">
			<h3 class="page-title">个人假期管理</h3>
			<ul class="breadcrumb">
				<li><i class="icon-home"></i> <a
					href="<c:url value="/home.html"/>">首页</a> <i
					class="icon-angle-right"></i></li>

				<li><a href="#">新增请假管理</a></li>
			</ul>
		</div>
	</div>
	<div class="control-group">
		<label class="control-label">姓名:</label>
		<div class="controls">
			<input type="text" name="name" class="m-wrap large"
				value="${member.realName}" readonly="readonly">
		</div>
	</div>


	<div class="control-group">
		<label class="control-label">类型:</label>
		<div class="controls">
			<select class="m-wrap span12" style="width:300px;"
				name="vacationtype">
				<option value="病假">病假(*)</option>
				<option value="年休假">年休假</option>
				<option value="婚假">婚假</option>
				<option value="产假">产假(流产假)</option>
				<option value="护理假">护理假</option>
				<option value="事假">事假(*)</option>
				<option value="丧假">丧假(*)</option>
				<option value="倒休">倒休</option>

			</select>
			<h6>注：带*需注明原因 病假需提供医院证明</h6>

		</div>

	</div>

	<div class="control-group">
		<label class="control-label">原因:</label>
		<div class="controls">
			<input type="text" name="cause" class="m-wrap large">
		</div>
	</div>


	<div class="control-group">
		<label class="control-label">开始时间:</label>
		<div class="controls">
			<input class="date-picker m-wrap large" name="startdate"
				id="startdate" type="text" value="" />
		</div>
	</div>

	<div class="control-group">
		<label class="control-label">结束时间:</label>
		<div class="controls">
			<input class="date-picker m-wrap large" name="enddate" id="enddate"
				type="text" value="" />
		</div>
	</div>

	<div class="control-group">
		<label class="control-label">请假天数:</label>
		<div class="controls">
			<select class="m-wrap span12" style="width:300px;" name="countdate">

				<option value="1">1天</option>
				<option value="2">2天</option>
				<option value="3">3天</option>
				<option value="4">4天</option>
				<option value="5">5天</option>
				<option value="6">6天</option>
				<option value="7">7天</option>
				<option value="8">8天</option>
			</select>
		</div>
	</div>

	<div class="control-group">
		<label class="control-label">特殊说明:</label>
		<div class="controls">
			<input type="text" name="special" class="m-wrap large">
		</div>
	</div>


	<div class="control-group">
		<label class="control-label">职务代理人:</label>
		<div class="controls">
			<select class="m-wrap span12" style="width:300px;" name="agent">


				<c:forEach var="row" items="${dataGrid.rows }">
					<option value="${row.realName}">${row.realName}</option>
				</c:forEach>

			</select>

		</div>

	</div>



	<div class="form-actions">
		<button class="btn blue" type="submit" onclick="return checkSearch()">
			<i class="icon-ok"> </i> 保存
		</button>
		<a href="<c:url value="/vacation/list.html"/>" class="btn black"
			type="button"> <i class="icon-share-alt"></i> 返回
		</a>
	</div>
</form>

<script type="text/javascript">
	$(".date-picker").datepicker({
		format : "yyyy-mm-dd",
		language : 'zh',
		clearBtn : true,
		autoclose : true
	});

	var start, end, flag = 0;

	$('#startdate').datepicker({
		format : 'yyyy.mm.dd',
		weekStart : 1,
		autoclose : true,
		todayBtn : 'linked',
		language : 'zh-CN'
	}).on('changeDate', function(ev) {
		var startTime = ev.date.valueOf();
		start = startTime;
		if (start > end) {
			flag = 1;
			alert("“开始时间 ”必须能早于“结束时间” ！");
			$("#startdate").focus();
		} else {
			flag = 0;
		}
	});

	$('#enddate').datepicker({
		format : 'yyyy.mm.dd',
		weekStart : 1,
		autoclose : true,
		todayBtn : 'linked',
		language : 'zh-CN'
	}).on('changeDate', function(ev) {
		var endTime = ev.date.valueOf();
		end = endTime;
		if (end < start) {
			flag = 2;
			alert("“结束时间 ”不能早于“开始时间 ” ！");
			$("#enddate").focus();
		} else {
			flag = 0;
		}
	});
	function checkSearch() {
		if (flag != 0) {
			if (flag == 1) {
				alert("“开始时间 ”必须能早于“结束时间” ！");
			}
			if (flag == 2) {
				alert("“结束时间 ”不能早于“开始时间 ” ！");
			}
			return false;
		}
		return true;
	}
</script>